<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>#div1{width:200px;height:200px;background-color: red;position: absolute;}</style>
    <script>
           document.onmouseover=function(ev){
             var oEvent=ev||event;
             var oDiv=document.getElementById('div1');
             oDiv.style.left=oEvent.clientX+'px';//oEvent.clientX获取横坐标，然后将横坐标赋给方块的left
             oDiv.style.top=oEvent.clientY+'PX';

           };
    </script>
</head>
<body>
<div id="div1"></div>
</body>
</html>